package cn.Mmovie.service.impl;

import cn.Mmovie.bean.Movie;
import cn.Mmovie.bean.Schedule;
import cn.Mmovie.dao.Impl.MovieDaoImpl;
import cn.Mmovie.dao.MovieDao;
import cn.Mmovie.service.MovieService;
import cn.Mmovie.util.PageUtil;

import java.util.List;

public class MovieServiceImpl implements MovieService {
    private MovieDao movieDao=new MovieDaoImpl();
    @Override
    public List<Movie> queryAllMovies() {
        return movieDao.selectAll();
    }

    @Override
    public PageUtil<Movie> page(Integer pageNo, Integer pageSize) {
        PageUtil<Movie> pageUtil = new PageUtil<>();
        pageUtil.setPageNo(pageNo);
        pageUtil.setPageSize(pageSize);
        pageUtil.setRecordCount(movieDao.selectForRecordTotal());
        pageUtil.setItems(movieDao.selectForPageItems((pageUtil.getPageNo() - 1) * pageUtil.getPageSize(), pageUtil.getPageSize()));
        pageUtil.setUrl("/admin/cinema_list?pageSize=" + pageUtil.getPageSize());
        return pageUtil;
    }

}
